import static java.lang.Math.max;
import static java.lang.Math.min;

public class TestGeometricObject {
    /**
     * Main method
     */
    public static void main(String[] args) {
        // Declare and initialize two geometric objects
        GeometricObject geoObject1 = new Circle(5);
        GeometricObject geoObject2 = new Rectangle(5, 3);
        GeometricObject geoObject3 = new Square(10,10);

        System.out.println(""+equalArea(geoObject1,geoObject2));
        System.out.println(""+equalArea(geoObject1,geoObject3));
        System.out.println(""+equalArea(geoObject2,geoObject3));


        // Display circle
        displayGeometricObject(geoObject1);

        // Display rectangle
        displayGeometricObject(geoObject2);
        displayGeometricObject(geoObject3);
        System.out.println("最大面积为"+max(geoObject1,geoObject2,geoObject3).getArea());
        System.out.println("最小周长为"+min(geoObject1,geoObject2,geoObject3).getPerimeter());
        //GeometricObject maxAreaObject = maxArea(geoObject1, geoObject2, geoObject3);
    }




    public static boolean equalArea(GeometricObject object1,GeometricObject object2) {
        return object1.getArea()== object2.getArea();
    }



    /**
     * A method for comparing the areas of two geometric objects
     */
    public static GeometricObject max(GeometricObject object1,
                                          GeometricObject object2, GeometricObject object3) {
        GeometricObject result;
        if (object1.getArea() > object2.getArea()) result = object1;
        else result = object2;
        if (result.getArea() < object3.getArea()) result = object3;
        return result;
    }
    public static GeometricObject min(GeometricObject object1,
                                      GeometricObject object2, GeometricObject object3) {
        GeometricObject results;
        if (object1.getPerimeter() > object2.getPerimeter()) results = object1;
        else results = object2;
        if (results.getPerimeter() < object3.getPerimeter()) results = object3;
        return results;
    }


        /** A method for displaying a geometric object */
        public static void displayGeometricObject (GeometricObject object){
            System.out.println();
            System.out.println("The area is " + object.getArea());
            System.out.println("The perimeter is " + object.getPerimeter());


        }



}
